package com.imax.center.config;

import com.imax.center.constant.QueueConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    //传感器上报事件
    @Bean
    public Queue queue1() {
        return new Queue(QueueConstant.SENSOR_EVENT_QUEUE, true);
    }

    @Bean
    public DirectExchange manualAckExchange() {
        return new DirectExchange(QueueConstant.EXCHANGE_NAME);
    }

    @Bean
    public Binding manualAckBinding() {
        return BindingBuilder.bind(queue1())
                .to(manualAckExchange())
                .with(QueueConstant.ROUTING_KEY);
    }

}

